package com.myidis.mapper;

import com.myidis.entity.AnalysisIndex;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

public interface CIDIIndexManagementMapper {
    @Select("SELECT * FROM analysis_index;")
    @Results({
            @Result(property = "index", column = "分析指标"),
            @Result(property = "uniformity", column = "一致性"),
            @Result(property = "evaluate", column = "评价"),
            @Result(property = "combination", column = "指标组合"),
            @Result(property = "isUsed", column = "是否采用")
    })
    ArrayList<AnalysisIndex> all();

    @Select("SELECT * FROM analysis_index WHERE 指标组合 = #{combination};")
    @Results({
            @Result(property = "index", column = "分析指标"),
            @Result(property = "uniformity", column = "一致性"),
            @Result(property = "evaluate", column = "评价"),
            @Result(property = "combination", column = "指标组合"),
            @Result(property = "isUsed", column = "是否采用")
    })
    ArrayList<AnalysisIndex> getByCobination(int combination);

    @Select("SELECT * FROM analysis_index WHERE 指标组合 = #{combination} AND 一致性 = #{uniformity};")
    @Results({
            @Result(property = "index", column = "分析指标"),
            @Result(property = "uniformity", column = "一致性"),
            @Result(property = "evaluate", column = "评价"),
            @Result(property = "combination", column = "指标组合"),
            @Result(property = "isUsed", column = "是否采用")
    })
    ArrayList<AnalysisIndex> getOne(@Param("combination") int combination, @Param("uniformity") String uniformity);

    @Insert("INSERT intO analysis_index(分析指标, 一致性, 评价, 指标组合, 是否采用)"
            + " VALUES (#{index}, #{uniformity}, #{evaluate}, #{combination}, #{isUsed});")
    int insert(AnalysisIndex add);

    @Update("UPDATE analysis_index SET  一致性 = #{uniformity}, "
            + "评价 = #{evaluate},  是否采用 = #{isUsed} WHERE 分析指标 = #{index} and 指标组合= #{combination};")
    int update(AnalysisIndex upd);

    @Delete("DELETE FROM `idis`.`analysis_index` WHERE 分析指标 = #{index} and 指标组合= #{combination}")
    int delete(@Param("index")String index, @Param("combination")int combination);
}
